using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Comp单个字体 : MonoBehaviour
{
    // [SerializeField]private RectTransform rect范围;
    [SerializeField]private LayoutElement image适合大小;
    [SerializeField]private Image image;
    [SerializeField]private float size=1f;
    // [SerializeField]private Image image;

    private 艺术字体.字体 config;
    public string key
    {
        get
        {
            if (config == null) return "";
            return config.key;
        }
    }

    public void SetUp(艺术字体.字体 config,float size)
    {
        this.config = config;
        image.sprite = config.value;
        image.preserveAspect = true;
        SetSize(size);
    }

    public void SetSize(float s)
    {
        size = s;
        Setsize();
    }

    private void Setsize()
    {
        image.rectTransform.sizeDelta = new Vector2(size * config.x, size * config.y);
        // var ss = image.sprite.bounds.size;
        image适合大小.preferredWidth = size*config.x;
        image适合大小.preferredHeight = size*config.y;
    }
}
